<template>
  <div class="map-layer theme-Dark">
    <div
      class="iconfont expanded"
      title="图层管理"
      @click="showTools = !showTools"
      v-html="showTools ? '&#xe8d2;' : '&#xe8d2;'"
    />
    <el-collapse-transition>
      <div v-show="showTools">
        <div v-if="!sfyg" class="measure">
          <div class="mapOperation">
            <div><span class="iconfont" title="河流" :class="{active: hlxuan}" @click="clickHL()">河流</span></div>
          </div>
        </div>
        <div v-if="!sfyg" class="measure">
          <div class="mapOperation" />
        </div>
        <div class="measure">
          <div class="mapOperation">
            <div><span class="iconfont" title="遥感" :class="{active: ygdxxuan==1}" @click="clickYG()">遥感</span></div>
            <div><span class="iconfont" title="地形" :class="{active: ygdxxuan==2}" @click="clickDX()">地形图</span>
            </div>
          </div>
        </div>
        <div class="measure">
          <div class="mapOperation">
            <div><span
              class="iconfont"
              title="河流注记"
              :class="{active: zjxuan}"
              style="height: 100%;"
              @click="clickzj()"
            >河流注记</span></div>
          </div>
        </div>
        <slot name="bottom" />
      </div>
    </el-collapse-transition>
  </div>
</template>

<script>
export default {
  props: {
    show: {
      type: Boolean,
      default: true
    },
    sfyg: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {
      showTools: true,
      active: '',
      hlxuan: true,
      zjxuan: false,
      ygdxxuan: '',
      center: false,
      sfhl: false,
      visible: false,
      radios: 1
    }
  },
  created() {
    if (this.$route.query.sxname) {
      this.active = 3
      // this.$emit('showSYLayer')
    }
  },
  mounted() {
    this.showTools = this.show
  },
  methods: {
    // 点击地市
    clickDS() {
      if (this.active == '1') {
        this.active = ''
      } else {
        this.active = '1'
      }
      this.$emit('showDSLayer', { txt: this.active })
    },
    // 点击区域
    clickQY() {
      if (this.active == '2') {
        this.active = ''
      } else {
        this.active = '2'
      }
      this.$emit('showQYLayer', { txt: this.active })
    },
    // 点击水系
    clickSY() {
      if (this.active == '3') {
        this.active = ''
      } else {
        this.active = '3'
      }
      this.$emit('showSYLayer', { txt: this.active })
    },
    // 点击河流
    clickHL() {
      // this.radios=1
      if (this.hlxuan) {
        this.hlxuan = false
        this.visible = false
      } else {
        this.hlxuan = true
        this.visible = true
      }
      this.$emit('showHLLayer', { radios: this.radios })
    },
    clickzj() {
      if (this.zjxuan) {
        this.zjxuan = false
      } else {
        this.zjxuan = true
      }
      this.$emit('showZJLayer', { radios: this.zjxuan })
    },
    gaibianzhi() {
      this.visible = false
      this.$emit('qieHLLayer', { radios: this.radios })
    },
    // 点击遥感
    clickYG() {
      if (this.ygdxxuan == 1) {
        this.ygdxxuan = ''
      } else {
        this.ygdxxuan = 1
      }
      this.$emit('showYGLayer', { txt: this.ygdxxuan })
    },
    // 点击地形
    clickDX() {
      if (this.ygdxxuan == 2) {
        this.ygdxxuan = ''
      } else {
        this.ygdxxuan = 2
      }
      this.$emit('showYGLayer', { txt: this.ygdxxuan })
    }
  }
}
</script>

<style lang="scss" scoped>
.map-layer {
  width: 36px;
  height: auto;
  position: absolute;
  right: 40px;
  z-index: 100;

  .expanded {
    width: 36px;
    height: 36px;
    border-radius: 0.208vw;
    font-size: 1.2vw;
    text-align: center;
    line-height: 36px;
    margin-bottom: 0.2vw;
    border-radius: 4px;
    box-shadow: 0px 6px 20px 0px rgba(85, 94, 111, 0.16);
  }

  .measure {
    width: 36px;
    text-align: center;
    border-radius: 0.208vw;
    margin-bottom: 0.2vw;
    padding: 0;

    .iconfont {
      width: 36px;
      height: 36px;
      font-size: 1.2vw;
    }

    .mapOperation {
      div {
        padding: 0px;
        border-bottom: 1px solid #465F81;

        span.iconfont {
          font-size: 12px;
          display: inline-block;
          height: 0.89vw;
          line-height: 0.89vw;
          width: 100%;

          &:active {
            color: #ffffff;
            background: rgba(17, 167, 249);
          }

          &.active {
            color: #ffffff;
            background: rgba(17, 167, 249);
          }
        }
      }

      div:last-child {
        border: 0;
      }
    }
  }
}

.iconfont {
  cursor: pointer;
}

.theme-Dark {
  .expanded {
    background: rgba($color: #1a4780, $alpha: 0.8);
    border: solid 1px #175b9b;
    color: #bcdff5;
  }

  .measure {
    background-color: rgba($color: #032a5b, $alpha: 0.8);
    border: solid 1px #175b9b;

    .iconfont {
      color: #bcdff5;
    }
  }
}

.theme-Light {
  .expanded {
    background: rgba($color: #ffffff, $alpha: 0.5);
    border: solid 1px #43b6ff;
    color: #43b6ff;
  }

  .measure {
    background: rgba($color: #ffffff, $alpha: 0.5);
    border: solid 1px #43b6ff;

    .iconfont {
      color: #43b6ff;
    }
  }
}
</style>
